<div id="thread-header">
  <h1 style="margin: 0px"><%=h @forum_thread.title %></h1>
  From <%= link_to @forum_thread.forum.title, forum_path(@forum_thread.forum) %>
  <br />
  <br />
</div><!-- /thread-header -->

<div id="errors">
  <%= error_messages_for(:post) %>
</div><!-- /errors -->

<div id="full-thread">
  <% @forum_thread.posts.oldest_first.each do |post| %>
    <div class=post>
      <table>
        <tr class="post-header">
         <td>Posted at: <%=h post.created_at.strftime('%d-%m-%y %I:%M %p') %></td>
         <td></td>
        </tr>

        <tr class="post-main">
          <td class="post-user">
            <%= link_to post.user.username, user_path(post.user) %>
          </td>
          <td class="post-body">
            <%=h post.text %>
          </td>
        </tr>

        <tr class="post-footer">
          <td style="border-right: 1px solid #6C6"></td>
           
          <td>
          <% if post.updated_at != post.created_at %>
            <hr />
            Last edited at: <%=h post.updated_at.strftime('%d-%m-%y %I:%M %p') %>
          <% end %>
          </td>
        </tr>

        <tr>
          <td style="border-right: 1px solid #6C6"></td>
          <td class="post-edit">
            <%= link_to 'Mark as Spam' %>
            <% if permitted_to? :edit, post %>
              <%= link_to 'Edit', edit_post_path(post) %>
            <% end %>
            <% if permitted_to? :destroy, post %>
              <%= link_to 'Delete', post, :controller => :posts, :method => :delete, :confirm => "Are you sure?" %>
            <% end %>
          </td>
        </tr>

      </table>
    </div>
  <% end %>
</div>

<% if permitted_to? :new, :posts %>
  <div id="thread-reply">

    <h3>Reply</h3>

    <% form_for @post do |post| %>
      <%= post.text_area :text, :rows => 10 %><br />
      <%= post.hidden_field :forum_thread_id, :value => @forum_thread.id %>
      <%= post.submit "Reply" %>
    <% end %>

  </div>
<% end %>
